package fr.istic.linkedcv.client.presentation.clickhandlers;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;

import fr.istic.linkedcv.client.presentation.Ui;
import fr.istic.linkedcv.client.services.PersonneService;
import fr.istic.linkedcv.client.services.PersonneServiceAsync;

public class ExitGroupeClickHandler implements ClickHandler {
	private String groupeName;
	private final PersonneServiceAsync personneServiceAsync = GWT.create(PersonneService.class);
	private Ui ui;
	public ExitGroupeClickHandler(String name, Ui ui) {
		groupeName = name;
		this.ui = ui;
	}

	@Override
	public void onClick(ClickEvent event) {
		personneServiceAsync.exitGroupe(groupeName, new AsyncCallback<Boolean>() {
			
			@Override
			public void onSuccess(Boolean result) {
				ui.fireCurrentHistoryState();
				
			}
			
			@Override
			public void onFailure(Throwable caught) {
				
				
			}
		});
	}

}
